//var webSiteUrl = 'http://192.168.0.119:801';
var webSiteUrl = 'http://fyb.59156.cn';
// var webSiteUrl = 'http://www.gfjijin.cn';

var apiKey = 'wx00ebcf3ca5271e58';
var mchId = '1525589741';
var partnerKey = 'SHANGHAISHANGHAISHANGHAISHANGHAI';
var notifyUrl = 'http://fyb.59156.cn/home/pay/wxnotify';
//var notifyUrl = 'http://www.gfjijin.cn/home/pay/wxnotify';

var appId = '2019080760954378';
var rsaPriKey = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCDvFXhR6sv+vbBcJAJ+UCDT1msUaXLMBkC9S2mHGbXXFI9sPkdeASVS6LNLxzL6tXe/WLF2y9iFZ9TT6GuygN55/UksiXnOOuUS2wFDydxwkyMGoohZkwt2N5nzpEZl5uFzjtlMtBdZ/yyqWAKaUJzQ03Sd2kVGGIwiZpx3K5SsaKguabnjzB7abozrYhmN5OfcqbVl6pqTiiCh3yK7MbAANesXEbvWu8cH0slCcQfilby/fHO88VxMVvJC03L+A929kX+UEVFPOsu/8FtUhDwaxGn451NPu18+E0crgB3jRUu/r6DhpWJ6YreN5LdyARftIV3q8/CSaf7ZwLT784hAgMBAAECggEAExTzx6cO9+s9VPXOF3PAUYTr81b8UftMlC4Zh6czilx4GTGKVCdvWoTTNy9s12jTw/ImHYzLR0TkiDfPrrbaXA0qaD9Z2C1ZimiGZBE24HaJif3KJl5gCIASbyzvvapFP9OIrPb4UZ9fbi20mK14j6OfIS5kzUZz6p3z/iw+IAIdf7fMmei9kH0Rkv+UN+Y1WVYpdeUDok1LBYtjTOMJ7u7l1+Z3c7avWvC1z6KE651iiioGmGdBzLT4ZDg1D/MeIrEEeVu3NIsfoNyK5pShWes5EIE27fyyU7KHXOeAfLOb1rlPV8jH6y0gZIzv2CtPY9zSPhgXjUphZ+tOEVYp1QKBgQD3NTpKBn7fS2hEEo+v/6Bqeim6eD38fOXW1ntXv/jpXzCtegf0YhEhkVDMUtxgVyMtBbdTkYlVPtVCsnxPC0I9H4ssYx657o5TKoqLBbUSvqda3nDmXbPW3hKKap/JPwk0r4Ry/nckeFX1VnHt3VKCwxDtAWaEZMH0ScWO4XoohwKBgQCIa8JXQDjPJTOlUfoihVJVaUFnqEeLDNpvh3gEURr/wx0AIhY1GUxqt6bAnJyIpLeTb1LXPLEPW7vUPFLS2Itfd1fr/pbz8AJEvjQeuWP8bT0e9/xssIEFZ6woKVy71xR18QF63yeO8xNJHSlivYyTPmjpeU8X0hWVsr5/OqUGFwKBgFvSmpcaeI/Ke60lU9fk1JoYTF2mAihB4EF/o4sBlJxirjsRo9jDgGd+iYuLj639T+SORf01htRyJVbD42ac4PrBN7nCC4y2roj3uURQV2TiClm3XCpFTeKW1D4zwqxGzM2UEFeCa5DRXeRmOqVG2zoU6LmQFptArcZmjIo4+F4LAoGACvjXxZq1tvtf/wDr5FDiwVnY19RyBJ4BB41WusonKMDxmSwkqxqgyciBkeZGtLrCxQnkGMmZ2Alhvv0nECw4cXIw0RtF2tLH6+18VahFgWzryIzbcYZ0qhGfiA9jlPwEekPrAY3nKZklSPEefgGOx9zyJS0LjnfoIoUgyyzVTvsCgYEAwhp4gFgObWxMNapiUeF0DzRcUqv32Rwrh+dNxNgr7gn5HyjJklITHmzsUfVFB9GdI+BgiKd0bT5KaYeifP3N846eMc+2GgBDQA6P8duy5TD9lV/cJ9LfV7MIayyq9Feb7mxF05ximDuKeuBqZm7Z6mfH0CIo22odhlY+KvW1vTM=';
if($api.getStorage('user') != null && $api.getStorage('user') != "undefined"){
    var user=$api.getStorage('user');
    var isvip=user.vip;
    var token=user.token;
    var uid=  user.id;
    var utype=  user.type;
    var vip= user.vip;
    var balance= user.balance;

    var loginphone=  user.phone;

    var webphone=  user.webphone;

    var islogin=1;
}else{

    var islogin=0;
}


//检测qq
function check_qq(){
  var qq = api.require('qq');
  var openId = '';
  qq.installed(function(ret, err) {
      if (!ret.status) {
          $(".qq").hide();
      } else {

      }
  });
}
//检测微信
function check_wx(){
  var wx = api.require('wx');
  var code = '';
  wx.isInstalled(function(ret, err) {
      if (!ret.installed) {
          $(".wx").hide();
      } else {

      }
  });
}
//检测微博
function check_wb(){
  var weibo = api.require('weibo');
  weibo.isInstalled(function(ret) {
      if (!ret.status) {
          $(".wb").hide();
      } else {

      }
  });
}



//下拉刷新
function toDoRefresh() {
  setTimeout(function() {
    location.reload();
    api.refreshHeaderLoadDone(); //复位下拉刷新
    api.toast({
      msg: '刷新成功',
      duration: '1000',
      localtion: 'middle'
    });
  }, 2000)
}

//通用检测tokens跳转
function commonUrl(url){

    var result = loginCheck();

  if(result == false){
    return false;
  }
  api.openWin({
      name: url,
      url: url+'.html',
      reload:true,
      pageParam: {

      }
  });
}

function loginCheck() {

  if(token==''||token==null||token==undefined){
      alert('您尚未登录,请登录');
      api.openWin({
          name: 'login',
          url: 'login.html',
          reload:true,
          pageParam: {

          }
      });
      return false;
  }else{
    var p ={token:token}
    console.log(JSON.stringify(token))
    api.ajax({
        url: webSiteUrl + '/App/home/checkIndividual',
        method: 'post',
        data: {
            values: p
        }
    }, function(ret, err) {
      console.log(JSON.stringify(ret));
      if(ret.code==501){
        alert('您尚未登录,请登录')
        api.openWin({
            name: 'login',
            url: 'login.html',
            reload:true,
            pageParam: {

            }
        });
      }
    })
    return true;

  }
}

function orderNumber() {
    return parseInt((Math.random() + 1) * Math.pow(10,12-1))
}

function ck(str) {
    if(str.indexOf('http')==0){
        return true;
    }else{
        return false;
    }
}
var kong='<p style="text-align:center;">暂无数据</p>';

function personal () {
    var result = loginCheck();
  if(result == false){
    return false;
  }

  api.openWin({
      name: 'personal',
      url: 'personal.html',
      reload: true,
      pageParam: {

      }
  });

/*    if(token==''){
        aaplay('login_account')

    }else{
        aaplay('personal')
    }*/


}



    function loginPlay () {
        api.openWin({
            name: 'loginName',
            url: './login.html',
            reload:true,
            pageParam: {
                name: 'text'
            }
        });

    }

    function forgetPlay () {
        api.openWin({
            name: 'loginName',
            url: './forget.html',
            reload:true,
            pageParam: {
                name: 'text'
            }
        });

    }
    function indexPlay () {
        api.openWin({
            name: 'loginName',
            url: './slide.html',
            reload:true,
            pageParam: {
                name: 'text'
            }
        });
    }
    function newsdetail(id){
        api.openWin({
            name: 'news_info',
            url: 'news_info.html',
            reload: true,
            pageParam: {
                id: id,
            }
        });
    }
    function dtdetail(id){
        api.openWin({
            name: 'lawyer_dynamic_details',
            url: 'lawyer_dynamic_details.html',
            reload: true,
            pageParam: {
                id: id,
            }
        });
    }
    function hetongdetail(id){
        api.openWin({
            name: 'contract_details',
            url: 'contract_details.html',
            reload: true,
            pageParam: {
                id: id,
            }
        });
    }
	function detailPlay (name,id) {
	    api.openWin({
	        name: name,
	        url: name+'.html',
          reload:true,
	        pageParam: {
	            id: id,
	        }
	    });
	}
    function askdetail(id){
        api.openWin({
            name: 'faskdetail',
            url: 'faskdetail.html',
            reload:true,
            pageParam: {
                id: id,

            }
        });
    }
    function lawyer (id) {
        api.openWin({
            name: 'lawyer_details',
            url: './lawyer_details.html',
            reload:true,
            pageParam: {
                id: id,
            }
        });
    }
	function aaplay (name) {
       // alert(name);
	    api.openWin({
	        name: name,
	        url:  name+'.html',
            reload: true,
	        pageParam: {

	        }
	    });
	}
    function paplay (name,id) {
        api.openWin({
            name: name,
            url:  name+'.html',
            reload: true,
            pageParam: {
               id:id
            }
        });
    }
    function comeBack(){
        api.historyBack({
        },function(ret,err){
            if (!ret.status) {
                api.closeWin();
            }
        });
    }

    function yepay(money,orderno) {
        api.openWin({
            name: 'yepay',
            url: 'yepay.html',
            pageParam: {
                orderno:orderno,
                money:money,

            }
        });
    }
    $(function () {
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();

    });

    function winReload(winName, frameName) {
        var jsFun = 'location.reload();';
        api.execScript({
            name: winName,
            frameName: frameName,
            script: jsFun
        });
    }
